package com.ceam.orderservice.controller;

import com.ceam.orderservice.entity.Orders;
import com.ceam.orderservice.service.OrdersService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Orders)表控制层
 *
 * @author makejava
 * @since 2023-05-25 15:13:03
 */
@RestController
@RequestMapping("v1/orders")
public class OrdersController {
    /**
     * 服务对象
     */
    @Resource
    private OrdersService ordersService;

//    /**
//     * 分页查询
//     *
//     * @param orders      筛选条件
//     * @param pageRequest 分页对象
//     * @return 查询结果
//     */
//    @GetMapping
//    public ResponseEntity<Page<Orders>> queryByPage(Orders orders, PageRequest pageRequest) {
//        return ResponseEntity.ok(this.ordersService.queryByPage(orders, pageRequest));
//    }

//    /**
//     * 通过主键查询单条数据
//     *
//     * @param id 主键
//     * @return 单条数据
//     */
//    @GetMapping("amount/{id}")
//    public ResponseEntity<Orders> queryById(@PathVariable("id") Integer id) {
//        return ResponseEntity.ok(this.ordersService.queryById(id));
//    }

    @GetMapping("amount/{id}")
    public ResponseEntity<Orders> getOrderAmount(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.ordersService.getOrderAmount(id));
    }

    @GetMapping("state/{id}")
    public ResponseEntity<Orders> getOrderState(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.ordersService.getOrderState(id));
    }
    /**
     * 新增数据
     *
     * @param orders 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public ResponseEntity<Orders> add(@RequestBody Orders orders) {
        return ResponseEntity.ok(this.ordersService.insert(orders));
    }

//    /**
//     * 编辑数据
//     *
//     * @param orders 实体
//     * @return 编辑结果
//     */
//    @PutMapping
//    public ResponseEntity<Orders> edit(Orders orders) {
//        return ResponseEntity.ok(this.ordersService.update(orders));
//    }
//
//    /**
//     * 删除数据
//     *
//     * @param id 主键
//     * @return 删除是否成功
//     */
//    @DeleteMapping
//    public ResponseEntity<Boolean> deleteById(Integer id) {
//        return ResponseEntity.ok(this.ordersService.deleteById(id));
//    }

}

